﻿<!--#include file="../inc/common.asp" -->
<%
    if not userRightObj.canManage then
        message("您没有设置权限")
    end if
    call OpenDB
%>
<HTML><HEAD><TITLE><%=blogObj.blogTitle%>—控制面板—分类目录</TITLE>
<link rel="stylesheet" href="<%=cssFile%>" type="text/css" />

<style type="text/css">
td{
    font-size:10pt;
}
</style>
<body bgcolor="#c1c1c1" leftmargin="0" topmargin="0" style="font-size:10pt">
<div style="width:760px;height:100%;">

    <div style="float:left;width: 160px; padding-top:20px">
    <!--#include file="menu.asp" -->
    </div>

    <div style="background:#ffffff; width:580px; height:100%;float:left;padding:20px 10px 10px 10px">
<%
    dim cat_id, cat_name, cat_desc, display_seq, is_rss, rss_url
    cat_id = trim(request("cat_id"))
    if cat_id="" then
    
%>
<p>请选择要编辑的栏目分类：</p>
<%
        sql = " select cat_id, cat_name, cat_desc, display_seq from blog_category where blog_id=" & blogObj.blogId & " order by display_seq"
        rs.open sql, conn, 1, 1
        while not rs.bof and not rs.eof 
          cat_id=rs("cat_id")
%>
<p>&nbsp;&nbsp;<a href="category.asp?blog_id=<%=blogObj.blogId%>&cat_id=<%=cat_id%>"><%=rs("cat_name")%></a></p>
<%
          rs.moveNext()
        wend
        rs.close()
%>
<p>或者<a href="category.asp?blog_id=<%=blogObj.blogId%>&cat_id=-1">新增栏目分类</a></p>
<%  
    else
        cat_id = clng(cat_id)
        dim blogCat
        set blogCat = new BlogCatClass
        sql = " select cat_id, blog_id, cat_name, cat_desc, display_seq, is_rss, rss_url from blog_category where blog_id=" & blogObj.blogId & " and cat_id=" & cat_id
        rs.open sql, conn, 1, 3
        if rs.bof or rs.eof then
        else
            cat_name = rs("cat_name")            
            cat_desc = rs("cat_desc")
            display_seq = rs("display_seq")
            is_rss = rs("is_rss")
            rss_url = rs("rss_url")
        end if
        if request("actionType")=" 删除 " then
            rs.delete()

            blogCat.blogId = blogObj.blogId
            blogCat.catId = cat_id
            call blogCat.clean()
            blogObj.loadBlogCatsFromDB()
            call blogObj.cache()
            
            call closeDB()
            
            response.redirect("category.asp?blog_id="&blogObj.blogId)
            response.end
        elseif request("actionType")=" 保存修改 " then
            if rs.bof or rs.eof then
                rs.addNew()
                rs("blog_id")=blogObj.blogId
            end if
            cat_name = filterHTML(request("cat_name"))            
            cat_desc = filterHTML(request("cat_desc"))
            display_seq = filterHTML(request("display_seq"))
            if trim(display_seq)="" then
                display_seq = 1
            end if
            is_rss = request("is_rss")
            if is_rss="" then
            	is_rss = 0
        	end if
        	rss_url = filterHTML(request("rss_url"))
            rs("cat_name") = cat_name     
            if cat_desc <>"" then
                rs("cat_desc") = cat_desc
            else    
                rs("cat_desc") = null
            end if    
            rs("display_seq") = display_seq
            rs("is_rss")=is_rss
            rs("rss_url")=rss_url
            rs.update()
            cat_id = rs("cat_id")

            call blogCat.reload(blogObj.blogId, cat_id)
            blogObj.loadBlogCatsFromDB()
            blogObj.cache()
            
            
            response.write("<b>保存成功！</b><br> ")
        end if
        rs.close()
%>
	<script language=javascript>
	function RSSChanged(){
		if (form1.is_rss.checked){
		  form1.rss_url.disabled = false;
		}else{
		  form1.rss_url.disabled = true;
		}
	}
	</script>
    <form name=form1 action=category.asp method=post>
        <input type=hidden name=blog_id value="<%=blogObj.blogId%>">
        <input type=hidden name=cat_id value="<%=cat_id%>">
        <p>栏目名称：<input type=text name=cat_name size=60 value="<%=cat_name%>" </p>
        <p>栏目描述：<textarea name=cat_desc cols=59 rows=3 ><%=cat_desc%></textarea> </p>
        <p>显示顺序：<input type=text name=display_seq size=3 value="<%=display_seq%>"></p>
        <p><input type=checkbox name=is_rss size=3 value="1" <% if is_rss then response.write("checked") end if %> onclick="javascript:RSSChanged()" >RSS源：<input type=text name=rss_url size=50 value="<%=rss_url%>"><br>
        	<br>
        	 （如选中RSS源并填入正确的RSS地址后，本栏目内容将自动从该RSS源获取）
        </p>
        <p align=center><input type=submit name=actionType value=" 保存修改 ">
<%
      if cat_id<>"" and cat_id<>"-1" then 
%>
        <input type=submit name=actionType value=" 删除 " onclick="return confirm('注意：删除操作会同时删除该栏目分类下的所有文章及评论！！\n\n确定要删除吗？')">
<% 
      end if
%>
        <input type=button  value=" 返回 " onclick="document.location.href='category.asp?blog_id=<%=blogObj.blogId%>'">
        </p>
    </form>
<%
    end if    
%>

    </div>
<div>
</body>    
</html>    
<!--#include file="../inc/end.asp" -->
